<template>
	<div class="Body">
		<div class="search">
			<el-input placeholder="请输入进行搜索" v-model="input" clearable size="medium"
				style="width: 942px; margin-top: 36px">
				<el-button type="primary" style="background-color: #409eff; width: 80px" slot="append"
					icon="el-icon-search" @click="search()"></el-button>
			</el-input>
			<div class="hotSearch">
				<div>
					<a-menu mode="horizontal" style="display: flex; justify-content: space-around">
						<a-menu-item key="1" disabled> 搜索排行： </a-menu-item>
						<a-menu-item key="2"> 项目经理 </a-menu-item>
						<a-menu-item key="3"> Java开发 </a-menu-item>
						<a-menu-item key="4"> Web前端 </a-menu-item>
						<a-menu-item key="5"> 数据库开发 </a-menu-item>
					</a-menu>
				</div>
			</div>
		</div>
		<div class="containe">
			<!-- <Fliterss></Fliterss> -->
			<div class="Qintor">
				<Container></Container>
			</div>
			<div class="table">
				<el-table :data="data" stripe style="width: 100%">
					<el-table-column v-for="column in columns" :key='column.key' :label="column.title"
						:prop="column.key">
					</el-table-column>
					<el-table-column fixed="right" label="操作">
						<template slot-scope="scope">
							<!--editShow(scope.row.id)-->
							<el-button @click="editShow(scope.row.id)" type="warning" size="mini">投递</el-button>
						</template>
					</el-table-column>
					<!--  <el-table-column prop="apart" label="部门">
          </el-table-column>
          <el-table-column prop="address" label="地点">
          </el-table-column>
          <el-table-column prop="data" label="发布时间">
          </el-table-column>
          <el-table-column prop="updata" label="更新时间">
          </el-table-column> -->
				</el-table>
			</div>
			<!-- 分页插件 -->
			<el-pagination layout="total, sizes, prev, next, pager, jumper" @size-change="sizeChange"
				@current-change="currentChange" :page-sizes="[2, 5, 10, 50]" :page-size="2" :total="total">
			</el-pagination>
		</div>
	</div>
</template>



<script>
	import Container from "../index/QiyeContainer";
	import axios from "axios";
	
	// import Fliterss from "../index/fliter"
	const columns = [
		/* {
		  title: "id",
		  dataIndex: "id",
		  key: "id",
		  ellipsis: true,
		}, */
		{
			title: "职位名称",
			dataIndex: "postName",
			key: "postName",
			scopedSlots: {
				customRender: "post_name"
			},
		},
		{
			title: "公司部门",
			dataIndex: "department",
			key: "department",
			width: 100,
		},
		{
			title: "工作地点",
			dataIndex: "workAddress",
			key: "workAddress",
			ellipsis: true,
		},
		{
			title: "工作城市",
			dataIndex: "workCity",
			key: "workCity",
			ellipsis: true,
		},
		{
			title: "发布日期",
			dataIndex: "createdTime",
			key: "createdTime",
			ellipsis: true,
		},
		{
			title: "更新时间",
			dataIndex: "updatedTime",
			key: "updatedTime",
			ellipsis: true,
		},
	];

	const data = [{
			id: "1",
			postName: "JAVA工程师",
			department: "",
			workAddress: "北京科技有限公司",
			workCity: "北京",
			createdTime: "2015-12-28",
			updatedTime: "2015-12-18",
		},
	
		/* {
		  key: "2",
		  name: "Python工程师",
		  apart: "北京科技有限公司",
		  address: "北京",
		  data: "2015-12-28",
		  updata: "2015-12-18",
		},
		{
		  key: "3",
		  name: "JAVA工程师",
		  apart: "上海科技有限公司",
		  address: "上海",
		  data: "2015-12-28",
		  updata: "2015-12-18",
		}, */
	];
	
	const data2 = [{
			id: "1",
			postName: "JAVA工程师",
			department: "",
			workAddress: "北京科技有限公司",
			workCity: "北京",
			createdTime: "2015-12-28",
			updatedTime: "2015-12-18",
		}];
	
	const data3 = [{
			id: "1",
			postName: "JAVA工程师",
			department: "",
			workAddress: "北京科技有限公司",
			workCity: "北京",
			createdTime: "2015-12-28",
			updatedTime: "2015-12-18",
		}];

	export default {
		components: {
			Container,
		},
		data() {
			return {
				data,
				data2,
				data3,
				columns,
				type:0,
				pageNum: 1,
				size: 2,
				token:"",
				searchs: [],
				intervew:[{
					userAccount:"李荣浩", 
					token:"",
					userKey:"",
					type:1,
					postid:"",
					id:"",
					}],
				input: null,
				
			};
		},

		mounted() {
			this.list();
			
		},
		methods: {
			onSearch(value) {
				console.log(value);
			},
			created(id){
			    	//页面加载时就从本地通过localstorage获取存储的token值
					this.intervew.postid=id;
			        this.token =  localStorage.getItem('token');
					console.log(this.token);
					axios.get("http://localhost:9003/users/list",
						{params:{token:this.token}},
						).then((response)=>{
							this.type=response.data[0].type
							this.intervew.userAccount=response.data[0].userAccount;
							this.intervew.token=response.data[0].token;
							this.intervew.usersKey=response.data[0].usersKey;
							this.intervew.type=response.data[0].type;
							
							
							
					})
			    },
				editShow(id) {
					console.log(id+"edid");
					this.created(id);
					console.log("creater方法结束")
					console.log(this.intervew)
					
					this.$alert('是否提交简历', '提交简历', {
					    confirmButtonText: '确定',
					          callback: action => {
								  console.log(this.type)
								  if(this.type!=2){
									  action="只有个人用户才能进行投递"
									  this.$message({
									    type: 'info',
									    message: `投递失败: ${ action }`
									  });
								  }else{
									  axios.post("http://localhost:9003/interview/sendResume",
									  {postid:this.intervew.postid,userid:this.intervew.usersKey},
									  ).then((response)=>{
									  	console.log(response)
									  	action=response.data.message
									  	//f如果成功返回
									  	this.$message({
									  	  type: 'info',
									  	  message: `投递成功: ${ action }`
									  	});
									  	
									  })
								  }
								/* axios.post("http://localhost:9003/interview/sendResume",
								{postid:this.intervew.postid,userid:this.intervew.usersKey},
								).then((response)=>{
									console.log(response)
									action=response.data.message
									//f如果成功返回
									this.$message({
									  type: 'info',
									  message: `投递成功: ${ action }`
									});
									
								}) */
								  
					           
					          }
					        });
					    
				},
				
			sizeChange: function(s) {
				console.log(s);
				this.size = s;
				this.list();
			},
			currentChange: function(i) {
				console.log(i);
				this.pageNum = i;
				this.list();
			},
			search: function(input) {
				console.log(this.input);
				if (this.input == null || this.input == "") {
					this.data = this.data2;
					return;
				}else if(this.input =='企业'){
					this.$router.push("http://localhost:8080/start");
				}else{
					axios.get("http://localhost:9003/post/getcompanysinfo",
						{params:{content:this.input}},
						).then((response)=>{
							console.log(response.data.data.data);
							//response.data.data;
							//console.log(this.data)
							this.data3=response.data.data.data
							console.log(this.data3)
							this.data=this.data3
					})
				}
				
			},

			list: function() {
				axios.get("http://localhost:9003/post/list", {
					params: {
						pageNum: this.pageNum,
						size: this.size,
					}
				}).then((response) => {
					console.log(response.data);
					this.data = response.data.list;
					this.data2 = response.data.list;
					this.total = response.data.total;
				})
			},
			
		},
	};
</script>

<style scoped>
	.search {
		height: 100px;
	}

	.ant-carousel>>>.slick-slide {
		text-align: center;
		height: 300px;
		line-height: 300px;
		/* background: #364d79; */
		overflow: hidden;
	}

	.ant-descriptions-bordered .ant-descriptions-item-label,
	.ant-descriptions-bordered .ant-descriptions-item-content {
		padding: 16px 22px;
		border-right: 1px solid #e8e8e8;
	}

	.hotSearch {
		width: 800px;
		margin-left: 75px;
		margin-top: -30px;
	}

	.ant-menu-horizontal>.ant-menu-item:hover,
	.ant-menu-horizontal>.ant-menu-submenu:hover,
	.ant-menu-horizontal>.ant-menu-item-active,
	.ant-menu-horizontal>.ant-menu-submenu-active,
	.ant-menu-horizontal>.ant-menu-item-open,
	.ant-menu-horizontal>.ant-menu-submenu-open,
	.ant-menu-horizontal>.ant-menu-item-selected,
	.ant-menu-horizontal>.ant-menu-submenu-selected {
		color: #1890ff;
		border-bottom: none;
	}

	.Qintor {
		width: 940px;
		height: 350px;
		margin-left: 34px;
		margin-top: 48px;
	}

	.table {
		margin-top: -52px;
		/* margin: 31px; */
		margin-left: 34px;
		margin-right: 48px;
	}
</style>
